﻿<html>
<head>
<title>大奇門遁甲(Original/founded by Goran FU Chi Leung)</title>
<meta charset="utf-8"/>
<script language="JavaScript" src="_js/jquery.min.js"></script>
<script language="JavaScript" src="_js/jiqi.js"></script>
<script language="JavaScript" src="_js/purple_star.js"></script>
<script language="JavaScript" src="_js/qimen.js"></script>
<script language="JavaScript" src="_js/qimen_special.js"></script>
<script language="JavaScript">
$(document).ready(function(){
  document.write('<p>大奇門遁甲(Original/founded by Goran FU Chi Leung)</p>'+"\r\n");
  //
  var d = new Date();
  var g = 1;
  var id = prompt('d');
  if(id) {
    // input date
    d = new Date(
      (id.substr(0,4)), 
      (id.substr(4,2)-1), 
      (id.substr(6,2)), 
      (id.substr(8,2)), 
      (id.substr(10,2)));
    if(!d) {
      alert('format error');return;
    }
    g = id.substr(12,1);
  }
  /** **/
  var jiqi = QIMEN_STAR.jiqi.GetJiqiInfo(d.getFullYear(),d.getMonth()+1,d.getDate(),d.getHours(),d.getMinutes(),d.getSeconds());
  /*
  var d=new Date();
  var jiqi = QIMEN_STAR.jiqi.GetJiqiInfo(2013,11,26,8,9,15);
  */
  var table = $("<table border='0' bgcolor='gray' cellspacing='1'></table>");
  var tr = $("<tr></tr>");
  var _size = 27;
  for(var i = 0; i < _size; i++)
    $('<td bgcolor="white"></td>').appendTo(tr);
  for(var i = 0; i < _size; i++)
    tr.clone().appendTo(table);
  table.clone().appendTo($("body"));
  //
  var _kk = [[4,9,2],[3,5,7],[8,1,6]];
  var q = QIMEN_STAR.qimen.calc(jiqi);console.log(q);
  var q2 = new Array();
  var _td = $("td").css("font-size",'8px');
  
  //
  var qq = new Array();
  for(var i = 0; i < _size; i++) {
    qq.push(new Array());
    for(var j = 0; j < _size; j++) 
      qq[i].push(i*_size+j);
  }
  // 計中宮
  /*
  var _sx=3;_sy=3;
  for(var i = 0; i<3; i++) {
    for(var j = 0; j < 3; j++) {
      var m = _kk[i][j] - 1;
      //console.log(qq[_sy+i][_sx+j],_td[qq[_sy+i][_sx+j]]);continue
      $(_td[qq[_sy+i][_sx+j]]).html(
        q.house_door[m]+'　'+q.houses_god[m]+"<br />\n"+
      '　'+q.houses_star[m]+q.tin_pan[m]+"<br />\n"+
      '　　'+q.dei_pan[m]
        ).css("background-color","#CCFFCC");
    }
  }
  */
  //計八宮
  for(var i = 0; i < 9; i++){
    var _tmp = QIMEN_STAR.qimen2.calc(jiqi,i+1);
    q2[_tmp.dei_pan[4]] = _tmp;
    }
  //四宮
  for(var _k = 0; _k < 3; _k++) {
    for(var _m = 0; _m < 3; _m++) {
    var _center = q2[q.dei_pan[_kk[_k][_m] - 1]];
    /**
     *
     */
    for(var _i = 0; _i < 3; _i++) {
      for(var _j = 0; _j < 3; _j++) {
        //if(_i == 2 && _j == 2) continue;
        /**
         *
         */
        var _sx=_m*9 + _j*3,_sy=_k*9 + _i*3;
        var _q2 = q2[_center.dei_pan[_kk[_i][_j] - 1]];
        for(var i = 0; i<3; i++) {
          for(var j = 0; j < 3; j++) {
            var m = _kk[i][j] - 1;
            //console.log(qq[_sy+i][_sx+j],_td[qq[_sy+i][_sx+j]]);continue
            $(_td[qq[_sy+i][_sx+j]]).html(
              _q2.house_door[m]+'　　'+_q2.houses_god[m]+"<br />\n"+
            '　　'+_q2.houses_star[m]+_q2.tin_pan[m]+"<br />\n"+
            '　　　'+_q2.dei_pan[m]
              );
          }
        }
        /**
         *
         */
      }//
    }
    /**
     *
     */
    }
  }
  for(var _k = 0; _k < 3; _k++) {
    for(var _m = 0; _m < 3; _m++) {
    if((_k*3+_m)%2 == 1) continue;
    /**
     *
     */
    for(var _i = 0; _i < 3; _i++) {
      for(var _j = 0; _j < 3; _j++) {
        //if(_i == 2 && _j == 2) continue;
        /**
         *
         */
        var _sx=_m*9 + _j*3,_sy=_k*9 + _i*3;
        for(var i = 0; i<3; i++) {
          for(var j = 0; j < 3; j++) {
            //console.log(qq[_sy+i][_sx+j],_td[qq[_sy+i][_sx+j]]);continue
            $(_td[qq[_sy+i][_sx+j]]).css("background-color","#CCFFCC");
          }
        }
        /**
         *
         */
      }//
    }
    /**
     *
     */
    }
  }
  //
  for(var _i = 0; _i < 9; _i++) {
    for(var _j = 0; _j < 9; _j++) {
      $(_td[qq[_i*3+1][_j*3+1]]).css("background-color","#CCCCFF");
    }
  }
  for(var _i = 0; _i < 3; _i++) {
    for(var _j = 0; _j < 3; _j++) {
      $(_td[qq[_i*9+4][_j*9+4]]).css("background-color","#FFCCCC");
    }
  }
  //console.log($("td"));
});
/*
document.write("<pre>");
document.write(QIMEN_STAR.purple_star.CalYear(d.getFullYear(),d.getMonth()+1,d.getDate(),d.getHours(),d.getMinutes(),d.getSeconds()),"\r\n");
document.write(QIMEN_STAR.purple_star.CalMonth(d.getFullYear(),d.getMonth()+1,d.getDate(),d.getHours(),d.getMinutes(),d.getSeconds()),"\r\n");
document.write(QIMEN_STAR.purple_star.CalDay(d.getFullYear(),d.getMonth()+1,d.getDate(),d.getHours(),d.getMinutes(),d.getSeconds()),"\r\n");
var day = 1;
for(var i = 01; i < 13; i++)
  document.write(i,":",QIMEN_STAR.jiqi.GetBazi(2013,10,day,i*2,0,0).substr(4,4),"\t",QIMEN_STAR.purple_star.CalHour(2013,10,day,i*2,0,0),"\r\n");
document.write("</pre>");
*/
</script>
</head>
<body style="font-size:6pt">

</body>
</html>